import request from '@/utils/request'

// 获取商品父类
export function ApiGategories(params) {
  return request({
    url: `/products/gategories`,
    method: 'get',
    params
  })
}
// 获取商品子类
export function ApiGategoriesNode(params) {
  return request({
    url: `/products/nodeClasss`,
    method: 'get',
    params
  })
}
// 获取商品列表
export function ApiCommodityList(params) {
  return request({
    url: `/products/getAllProducts`,
    method: 'get',
    params
  })
}
// 获取秒杀商品列表
export function ApiCommoditySeckillList(params) {
  return request({
    url: `/products/getSeckillProducts`,
    method: 'get',
    params
  })
}
// 获取商品详情
export function ApiCommodityDetail(params) {
  return request({
    url: `/products/getProduct`,
    method: 'get',
    params
  })
}
// 购物车列表
export function ApiCartList(params) {
  return request({
    url: `/products/shopCart/list`,
    method: 'get',
    params
  })
}
// 购物车数据（根据id查数据）
export function ApiCartByIdList(data) {
  return request({
    url: `/products/shopCart/getAll`,
    method: 'post',
    data
  })
}
// 添加购物车
export function ApiAddCart(data) {
  return request({
    url: `/products/shopCart/add`,
    method: 'post',
    data
  })
}
// 删除购物车
export function ApiDeleteCart(data) {
  return request({
    url: `/products/shopCart/delete`,
    method: 'post',
    data
  })
}
// 购物车下单
export function ApiCreateOrder(data) {
  return request({
    url: `/products/shopCart/submit`,
    method: 'post',
    data
  })
}
// 立即购买
export function ApiBuyNow(data) {
  return request({
    url: `/neworder/buy`,
    method: 'post',
    data
  })
}
// 更改购物车商品数量
export function ApiUpdateCartNum(params) {
  return request({
    url: `/products/shopCart/update`,
    method: 'get',
    params
  })
}

// 下单支付
export function ApiConfirmPay(data) {
  return request({
    url: `/neworder/pay`,
    method: 'post',
    data
  })
}
// 取消支付
export function ApiCancelPay(data) {
  return request({
    url: `/neworder/close`,
    method: 'post',
    data
  })
}
//回收
export function neworderRecycle(data) {
  return request({
    url: `/neworder/recycle`,
    method: 'post',
    data
  })
}
// 退款：
export function neworderReturnOrder(data) {
  return request({
    url: `/neworder/returnOrder`,
    method: 'post',
    data
  })
}
//获取秒杀开始和结束时间
export function seckillget(params) {
  return request({
    url: `/seckill/get`,
    method: 'get',
    params
  })
}
//获取随机商品
export function getRandomProducts(params) {
  return request({
    url: `/products/getRandomProducts`,
    method: 'get',
    params
  })
}
//获取推荐商品
export function getRecommendProducts(params) {
  return request({
    url: `/products/getRecommendProducts`,
    method: 'get',
    params
  })
}
